<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <title>中科小店</title>
    <link rel="shortcut icon" href="favicon.ico"> 
    <link href="${basepath}/wuliuTemplate/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
   
</head>
 <style>
  @font-face {
      font-family: "iconfont";
      src: url('fonts/iconfont.eot'); /* IE9*/
      src: url('fonts/iconfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
      url('fonts/iconfont.woff') format('woff'), /* chrome, firefox */
      url('fonts/iconfont.ttf') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+*/
      url('fonts/iconfont.svg#iconfont') format('svg'); /* iOS 4.1- */
    }
  .iconfont {
      font-family:"iconfont" !important;
      font-size:16px;
      font-style:normal;
      -webkit-font-smoothing: antialiased;
      -webkit-text-stroke-width: 0.2px;
      -moz-osx-font-smoothing: grayscale;
    }
   
    html,body{height:100%;}
    *{margin:0;padding:0;}
    li{list-style:none;}
	a{text-decoration:none!important;cursor:pointer;}
    .show{display:block!important;}
	.wrapper{padding:40px 0;}
    .model-box{min-height:800px;border:1px solid #ddd;margin:0 auto;padding:20px;}
    .new-btn{background:#44BB00;color:#fff;}
    .new-btn:hover{color:#f8f8f8;}
    .template_list {padding:10px 0;}
    .template_list .list{margin-top:15px;background:#f8f8f8;overflow:hidden;zoom:1;height:50px;line-height:50px;border:1px solid #e8e8e8;padding:0 20px;}
    .template_list .list .name{float:left;height:50px;line-height:50px;}
    .template_list .list .right-con{float:right;height:50px;line-height:50px;}
    .template_list .list .right-con a{margin-left:20px;}
    .template_list .list .right-con .edit-time{color:#999;}
 </style>
    <body>
    <div class="shadow"></div>
    <div class="wrapper">
         <div class="model-box">
              <div><a  href="/system/templateWuliu/add" class="btn new-btn">新建运费模板</a></div>
              <ul class="template_list">
              <%  for( template in template_list ){  %>
                 <li class="list">
                      <div class="name">${template.template_name!}</div>
                      <div class="right-con">
                          <span class="edit-time">最后编辑时间 <span class="time">${template.createtime,"yyyy-MM-dd HH:mm:ss"}</span></span>
                          <a  href="/system/templateWuliu/edit/${template.id}" class="edit-btn">修改</a>
                          <a  class="delete-btn   delete"  data_id="${template.id!}">删除</a>
                      </div>
                  </li>
              
              <%   }  %>
              
                  <!-- <li class="list">
                      <div class="name">模板1</div>
                      <div class="right-con">
                          <span class="edit-time">最后编辑时间 <span class="time">2016-07-11 11:25</span></span>
                          <a class="edit-btn">修改</a>
                          <a class="delete-btn">删除</a>
                      </div>
                  </li>
                  <li class="list">
                      <div class="name">模板2</div>
                      <div class="right-con">
                          <span class="edit-time">最后编辑时间 <span class="time">2016-07-11 11:25</span></span>
                          <a class="edit-btn">修改</a>
                          <a class="delete-btn">删除</a>
                      </div>
                  </li> -->
              </ul>
         </div>
    </div>
    </body>
    <script src="${basepath}/wuliuTemplate/js/jquery.min.js"></script>
    <script src="${basepath}/vendor/js/bootstrap.min.js?v=3.3.6"></script>
    <script type="text/javascript" src="${basepath}/plugin/layer/layer.js"></script>
    <script src="${basepath}/plugin/support.js"></script>
    <script type="text/javascript">
	

    function Console(val)
    {
    	ret = "";
    	
    	if( arguments.length==0 )
    		ret = "未填写参数";
    	else
    		for(i=0;i<arguments.length;i++)
    		{
    			str = arguments[i];
    			ret += (typeof(str)=="object")?JSON.stringify(str):str;
    		}
    	
    	console.log(ret);
    }

    function Alert(val)
    {
    	ret = "";
    	
    	if( arguments.length==0 )
    		ret = "未填写参数";
    	else
    		for(i=0;i<arguments.length;i++)
    		{
    			str = arguments[i];
    			ret += (typeof(str)=="object")?JSON.stringify(str):str;
    		}
    	
    	alert(ret);
    }

   function Ajax(url,data,success,failed)
   {
	// 两种调用方式：
	// GET  -- Ajax(url,success,failed);
	// POST -- Ajax(url,postdata,success,failed);
	
	// 6 中可能的情况：
	// 1,n,n,n
	// 1,2,n,n
	// 1,2,3,n
	// 1,2,3,4
	// 1,n,2,n
	// 1,n,3,4
	
	var param = {};
	param.url = url;
	param.data = "";
	param.type = "get";
	param.success = function(ret){ if(!ret.state) layer.msg(ret.msg); };
	param.failed  = function(ret){
		layer.confirm("网络异常，是否重新加载？",{
			yes:function(){ location.reload(true); },
			cancel:function(){ history.back(); }
		});
	};
	
	switch(arguments.length)
	{
		case 2:
			if( typeof(arguments[1])!="function" )
			{
				param.type = "post";
				param.data = arguments[1];
			}
			else
				param.success = arguments[1];
			break;
		case 3:
			if( typeof(arguments[1])!="function" )
			{
				param.type = "post";
				param.data = arguments[1];
				param.success = arguments[2];
			}
			else
			{
				param.success = arguments[1];
				param.failed  = arguments[2];
			}
			break;
		case 4:
			param.type    = "post";
			param.data    = arguments[1];
			param.success = arguments[2];
			param.failed  = arguments[3];
			break;
	}
	
	// 显示加载提示
	layer.load();
	
	$.ajax({
		url:param.url,
		type:param.type,
		data:param.data,
		dataType:"json",
		success:function(ret){
			layer.closeAll();
			param.success(ret);
//			Console("Ajax Return : ",ret);
		},
		error:function(ret){
			layer.closeAll();
	    	param.failed(ret);
		}
	});
    
}
</script>

<script type="text/javascript">
$(".delete").click(function(){
	var template_id=$(this).attr("data_id");
	   //alert(template_id);
	   ///return;
	    var param = {};
	    param.url="/system/templateWuliu/deleteTemplate";
	    param.type    = "post";
		param.data    = {"template_id":template_id};
	    gx.confirm("您是否确定删除此条模版？",function(){
		   $.ajax({
				url:param.url,
				type:param.type,
				data:param.data,
				dataType:"json",
				success:function(ret){
					layer.msg("成功");
					window.location.reload();
					/* layer.closeAll();
					param.success(ret); */
//					Console("Ajax Return : ",ret);
				},
				error:function(ret){
					layer.msg("请稍后再试");
					
					/* layer.closeAll();
			    	param.failed(ret); */
				}
			});
		   
		
	})
}) 	  

</script>

</body>
</html>